use image::RgbaImage;
use rstest::rstest;

use super::super::*;
use crate::tests::fixtures::{rand_string, rand_usize, random_text_tile_content_vector, test_data};

#[test]
fn test_tile_content_empty_raw_initialization() {
    if let TileContent::Empty = TileContent::Empty {
    } else {
        panic!("Expected the Empty variant, got something else")
    }
}

#[rstest]
fn test_tile_content_text_raw_initialization(
    #[values(
        vec![],
        vec!["".to_string()],
        vec![rand_string(1)],
        vec![rand_string(9)],
        random_text_tile_content_vector()
    )]
    content: Vec<String>,
) {
    let text_content = TileContent::Text(content.clone());
    if let TileContent::Text(text_content) = text_content {
        assert_eq!(text_content, content);
    } else {
        panic!("Expected the Text variant, got something else")
    }
}

#[rstest]
fn test_tile_content_raster_raw_initialization(
    #[values(
        DynamicImage::ImageRgba8(RgbaImage::new(0, 0)),
        DynamicImage::ImageRgba8(
            RgbaImage::new(rand_usize(1, 10) as u32, rand_usize(1, 8) as u32)
        ),
        image::open(test_data("four_raster_image_tiles/pixel/blue_pixel.png"))
            .expect("blue_pixel.png should be accessible"),
        image::open(test_data("four_raster_image_tiles/pixel/tile-small.jpg"))
            .expect("tile-small.jpg should be accessible"),
        image::open(test_data("four_raster_image_tiles/some/other/red-white.dds"))
            .expect("red-white.dds should be accessible"),
    )]
    content: DynamicImage,
) {
    let raster_image_content = TileContent::Raster(content.clone());
    if let TileContent::Raster(raster_image_content) = raster_image_content {
        assert_eq!(raster_image_content, content);
    } else {
        panic!("Expected the Raster variant, got something else")
    }
}
